{{$user_info=$session.user_info}}

<div class="right maindouble"> 
  
  <!--search end-->
  <div class="inright">
    <h4 class="qieh"><a >青币兑换</a></h4>
    <div class="xuaninfo fongbg"> 
    {{foreach from=$goods_list item=list key=key}}
      <div class="xuanlist">
        <dl>
          <dt><a  title="简介：{{$list.goods_desc}}"><img src="{{$list.goods_thumb}}" width="220" height="150"/></a></dt>
          <dd class="haoping"><a > {{$list.goods_name}}</a></dd>
          <dd style="font-size:14px;"> <strong>青币:<span class="text-danger">{{$list.shop_priced}}</span></strong> 
          {{if $user_info}}
          
              {{if $user_info.mag}}
              <a class="label label-danger pointer" onclick="setGolds('{{$list.shop_priced}}','{{$list.goods_name}}')">点击兑换</a>
              {{else}}
               <a class="label label-danger pointer" onclick="alert($('.pop').html())">点击兑换</a>
              {{/if}}
          {{else}}
          <a class="label label-danger pointer" href="main.php?act=user_login">请登录</a>
          {{/if}}
          {{if $is_cat_admin}}  <a class="label label-danger pointer" href="main.php?act=goods_edit&goods_id={{$list.goods_id}}">修改</a>{{/if}}
           </dd>
        </dl> 
      </div>
      {{/foreach}} </div>
    {{include file="../pager.htm"}} </div>
  <!--xuaninfo end--> 
  
</div>
<div class="none pop">
"团聚小区"行动的目的是实现"产品"的交互，因此只有店铺持有的青币才能用来兑换礼品或道具哟~个人持有的青币可以用来购买其他小店的产品。帮助你的小店积累更多的青币吧！
</div>

{{$user_info=$session.user_info}}

<script>
	

//积分兑换
 function setGolds(shop_priced,goods_name){
	 var data = new Object;
	 var user_gold = '{{$user_info.gold}}';
	 data.buyer = 'u_{{$user_info.user_id}}';
	 data.geter = 'c_{{$cat.cat_id}}';
	
	 data.type = '4'; //积分兑换 
	 data.amount = shop_priced;
	
	
	 
	 if((user_gold-data.amount >=0) && chk.isInteger(data.amount))
	 {
		
		 data.comment = '{{$user_info.user_name}} 兑换 '+goods_name+' 支出 '+data.amount+' 积分 操作人:{{$user_info.user_name}}' ;
		
		 var da = "act=send_gold&order_status=true&data="+$.toJSON(data);
		 Main.AJAX(sep+"/ajax.php",da,setGoldRes)
	 }
	 else
	 {
		alert("您的余额不够!");	 	 
	 }
  }
  
 function setGoldRes(res){
	if(res)
	{
		alert("兑换成功!");
	
		location.href = location.href;
		//location.href = 'checkouts.php?act=redirect&order_code='+res;	
	}
	else
	{
		alert("您的余额不够!");
		return false;
		//location.href = location.href;	
	}
 }
  
 
</script>